<template>
  <view class='myinfo'>
    <view
      class="myinfo_list"
      v-if="flag"
    >
      <view
        class="myinfo_ul"
        v-for="item in getData"
        :key="item.id"
      >
        <view class="myinfo_li">
          <view class="text1">姓名： {{item.name}}</view>
          <view class="text1">学号： {{item.code}}</view>
          <view class="text1">离院时间： {{item.liyuanTime}}</view>
          <view class="text1">离院状态： {{item.liyuanState}}</view>
        </view>
      </view>
    </view>
    <!-- 暂无记录 -->
    <!-- <view
      class="no_myinfo"
      v-else
    >
      <image
        src="../../static/index/noData.png"
        class="img"
      ></image>
    </view> -->
    <nut-empty v-else description="暂无记录"></nut-empty>
    <!-- 退出 -->
    
    <!-- <view
      class="outLogin"
      @tap="tuichu"
    >退出登录</view> -->
  </view>
  <view class="btn_box">
    <nut-button type="default" @tap="tuichu" block>退出登录</nut-button>
  </view>
</template>
<script>
import './liyuanjilu.less'
import Taro, { useRouter, getCurrentInstance } from '@tarojs/taro'
export default {
  data() {
    return {
      flag: true,
      getData: [
        { id: 1, name: '学生', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        { id: 2, name: '学生2', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        { id: 3, name: '学生3', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 4, name: '学生', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 5, name: '学生2', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 6, name: '学生3', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 7, name: '学生', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 8, name: '学生2', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 9, name: '学生3', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
        // { id: 10, name: '学生', code: '123456789', liyuanTime: '2022-06-18至2022-06-30', liyuanState: '已离院' },
      ]
    }
  },
  methods:{
    //退出登录
    tuichu() {
      const userInfo = Taro.getStorageSync("userInfo");
      var id = userInfo?.["wechat_id.id"];
      let that = this;
      that.flora.dash.dataApi
        .save({
          vars: {
            model: "FreshWechat",
            values: {
              id: id,
              open_id: "",
            },
          },
        })
        .then((res) => {
          console.log("-goOut=>", res);
          if (res.result.status === "ok") {
            Taro.clearStorageSync();
            Taro.clearStorage();
            // Taro.showToast({
            //     title: '退出成功',
            //     icon: 'success',
            // })
            // Taro.showToast('退出成功', 'success')
            Taro.redirectTo({ url: "/pages/login/login" }); //退出成功页面跳转
            return;
          }
          showToast("退出失败请重试~");
        });
    },
  }
}
</script>
<style>
</style>